'use strict';
const Readable = require('stream').Readable;

class SelfReadable extends Readable {
    constructor(iterator) {
        super();
        this.iterator = iterator;
    }
    _read() {
    	const res = this.iterator.next();
    	if(res.done){
    		return this.push(null);
    	}else {
    		this.push(res.value + '\n');
    	}
    }
}
module.exports = SelfReadable;